﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CCPnuts.ISkyDiskFileSystem.Interfaces;
using System.IO;
using CCPnuts.Pack;

namespace TestSkyDiskFileSystem
{
    class SkyElement : PackedBase, I_SkyElement
    {
        public SkyElement(PackedInfo info) : base(info) { }

        #region I_SkyElement Members

        public string Name { get; set; }

        public I_SkyElementContainer Parent { get; set; }

        /// <summary>
        /// Don't Support Copy.
        /// </summary>
        /// <param name="tarDir"></param>
        public void CopyTo(I_SkyElementContainer tarDir)
        {
            throw new NotSupportedException();
        }

        public I_Downloader Download(string targetPath)
        {
            return new Downloader(this as SkyFile)
            {
                TargetPath = targetPath,
                Target = this
            };
        }

        public virtual void MoveTo(I_SkyElementContainer tarDir)
        {
            tarDir.Children.ToList().Add(tarDir);
            Parent.Delete(this);
        }

        #endregion
    }
}
